<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据分析</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/crowdfund/analyze_list.css">
</head>
<%@include file="../include/header.jsp" %>
<body>
<div class="index-outside">
    <section class="no-fix">
        <div class="section-main">
            <div class="layui-tab layui-tab-brief mt20"  lay-filter="zc">
                <ul class="layui-tab-title">
                    <li class="layui-this" id="funding">众筹<span id="total_1" class="pl5">${count.all}</span>人
                    </li>
                    <li class="" id="directPay">直接付款<span id="total_2" class="pl5">${directCount.all}</span>人
                    </li>

                    <li class="form-item-inline" style="float:right; right:80px;">
                        <span class="b f16">众筹总资金：<span
                                class="active-red">${totalAmount}元</span>
                        </span>
                    </li>
                </ul>
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/crowdfund/analyze/list.do?targetId=${projectAnalyze.targetId}&eventId=${projectAnalyze.eventId}" id="myForm" method="post">
                        <%--<input type="hidden" name="pageNo" id="pageNo"/>--%>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content"> <%-- class="layui-tab-title" id="zc_tab" --%>
                                    <li class="form-item">
                                        <label class="search-form-lable">众筹人数</label>
                                        <div class="check-btn-inner" id="successes">
                                            <a href="javascript:void(0);"
                                               onclick="switchType($(this),'','#myForm')" ${empty projectAnalyze.isSuccess ? 'class="active"' : ''}>全部<span
                                                    class="p5 f16 b">${count.all}</span>人</a>
                                            <a href="javascript:void(0);"
                                               onclick="switchType($(this),0,'#myForm')" ${projectAnalyze.isSuccess == 0 ? 'class="active"' : ''}>众筹中<span
                                                    class="p5 f16 b">${count.underway}</span>人</a>
                                            <a href="javascript:void(0);"
                                               onclick="switchType($(this),1,'#myForm')" ${projectAnalyze.isSuccess == 1 ? 'class="active"' : ''}>众筹成功<span
                                                    class="p5 f16 b">${count.success}</span>人</a>
                                            <a href="javascript:void(0);"
                                               onclick="switchType($(this),3,'#myForm')" ${projectAnalyze.isSuccess == 3 ? 'class="active"' : ''}>退款中<span
                                                    class="p5 f16 b">${count.refunding}</span>人</a>
                                            <a href="javascript:void(0);"
                                               onclick="switchType($(this),4,'#myForm')" ${projectAnalyze.isSuccess == 4 ? 'class="active"' : ''}>退款成功<span
                                                    class="p5 f16 b">${count.refunded}</span>人</a>
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <a class="" href="javascript:javascript:void(0);"
                                           onclick="switchCondition();"><span id="upOrDown">展开</span><i
                                                class="iconfont icon-unfold"></i><i class="iconfont icon-fold"></i></a>
                                    </li>
                                </ul>
                            </div>
                        </div>

                        <input type="hidden" name="isSuccess" id="isSuccess"
                               value="${projectAnalyze.isSuccess}"/>
                        <%--<input type="hidden" name="targetId" id="targetId" value="${projectAnalyze.targetId}"/>
                        <input type="hidden" name="eventId" id="eventId" value="${projectAnalyze.eventId}"/>--%>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <div class="l-toggle-inner" style="margin-bottom: 10px;">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">众筹者</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="authorName" autocomplete="off"
                                                       class="layui-input" value="${projectAnalyze.authorName}"
                                                       placeholder="众筹者"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">联系电话</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="mobile" autocomplete="off"
                                                       class="layui-input" value="${projectAnalyze.mobile}"
                                                       placeholder="联系电话"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">目标金额</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="targetAmount" autocomplete="off"
                                                       class="layui-input" value="${projectAnalyze.targetAmount}"
                                                       placeholder="目标金额"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label
                                                class="search-form-lable">排序方式</label>
                                            <div class="layui-input-inline">
                                                <select name="sort" id="opSelect">
                                                    <%--                                                            <option value="0" ${projectAnalyze.sort == 0 ? 'selected="selected"' : ''}>金额最多</option>
                                                                                                            <option value="1" ${projectAnalyze.sort == 1 ? 'selected="selected"' : ''}>报名时间最近</option>
                                                                                                            <option value="5" ${projectAnalyze.sort == 5 ? 'selected="selected"' : ''}>成功时间最近</option>
                                                    &lt;%&ndash;                                                            <c:if test="${empty projectAnalyze.isSuccess }">
                                                                                                                <option value="5" ${projectAnalyze.sort == 5 ? 'selected="selected"' : ''}>成功时间最近</option>
                                                                                                            </c:if>&ndash;%&gt;
                                                                                                            <option value="2" ${projectAnalyze.sort == 3 ? 'selected="selected"' : ''}>支持数最多</option>
                                                                                                            <option value="3" ${projectAnalyze.sort == 3 ? 'selected="selected"' : ''}>阅读量最多</option>
                                                                                                            <option value="4" ${projectAnalyze.sort == 4 ? 'selected="selected"' : ''}>众筹用时最少</option>--%>
                                                </select>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">渠道</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="publisher" autocomplete="off"
                                                       class="layui-input" value="${projectAnalyze.publisher}"
                                                       placeholder="渠道"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">加好友</label>
                                            <div class="layui-input-inline">
                                                <select name="isFriend">
                                                    <option value="">全部</option>
                                                    <option value="0" ${projectAnalyze.isFriend == 0 ? 'selected="selected"' : ''}>否</option>
                                                    <option value="1" ${projectAnalyze.isFriend == 1 ? 'selected="selected"' : ''}>是</option>
                                                </select>
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">入群</label>
                                            <div class="layui-input-inline">
                                                <select name="isGroup">
                                                    <option value="">全部</option>
                                                    <option value="0" ${projectAnalyze.isGroup == 0 ? 'selected="selected"' : ''}>否</option>
                                                    <option value="1" ${projectAnalyze.isGroup == 1 ? 'selected="selected"' : ''}>是</option>
                                                </select>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label
                                                class="search-form-lable">筛选金额</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="amountGOE" autocomplete="off"
                                                       class="layui-input"
                                                       value="${projectAnalyze.amountGOE}"
                                                       placeholder="最小金额">
                                            </div>-
                                            <div class="layui-input-inline">
                                                <input type="number" name="amountLOE" autocomplete="off"
                                                       class="layui-input"
                                                       value="${projectAnalyze.amountLOE}"
                                                       placeholder="最大金额">
                                            </div>
                                        </li>
                                        <li class="form-item-inline" style="margin-left: -223px;"><label
                                                class="search-form-lable">区域</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="cityName" autocomplete="off"
                                                       class="layui-input" value="${projectAnalyze.cityName}"
                                                       placeholder="区域"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">公司</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="company" autocomplete="off"
                                                       class="layui-input" value="${projectAnalyze.company}"
                                                       placeholder="公司"
                                                >
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <ul class="search-form-content">
                                    <li class="form-item"><label class="search-form-lable">参与状态 </label>
                                        <div class="check-btn-inner" id="timeType">
                                            <a id="all" href="javascript:void(0);" class="active"
                                               onclick="mainApp.setLabel(this,'')">全部</a>
                                            <c:forEach var="label" items="${labelList}">
                                                <a href="javascript:void(0);"
                                                   onclick="mainApp.setLabel(this,'${label.id}')">${label.name}</a>
                                            </c:forEach>
                                            <input type="hidden" name="labelId"
                                                   value="${projectAnalyze.labelId}"/>
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger" href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a>
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:mainApp.reloadTable()">确定</a>
                                            <a class="layui-btn layui-btn-normal"
                                               href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <table id="analyze_table" class="analyze-table" lay-filter="analyze_table"></table>
                </div>
            </div>
        </div>
    </section>
</div>
<%@include file="../include/footer.jsp" %>
</section>
</div>

<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">

    $('.icon-unfold').show();
    $('.icon-fold').hide();
    $('.l-toggle-inner').hide();

    function switchCondition() {
        $('.l-toggle-inner').toggle();
        $('.icon-unfold').toggle();
        $('.icon-fold').toggle();
        $('.icon-unfold').css('display') == 'none' ? $('#upOrDown').html('收起') : $('#upOrDown').html('展开');
    }

    function switchType(obj, value, myForm) {
        $(obj).parent(".check-btn-inner").find("a").removeClass("active");
        $(obj).addClass("active");
        $(myForm).find("[name=isSuccess]").val(value);
        $(myForm).submit();
    }


    var element, laytable, analyzeT, mainApp, loadingIndex, layfrom;
    var dateList = JSON.parse(JSON.stringify(${dateList}));
    txz.initHeader({
        nav: [{
            name: '${projectAnalyze.eventId}' ? '众筹主题' : '众筹项目',
            href: '${projectAnalyze.eventId}' ? '${ctx}/crowdfund/event/list.do' : '${ctx}/activity/activity/zcActivityList.do',
        }, {
            name: '数据分析',
            curr: true
        }],
        btns: [{
            type: 'back'
        }]
    });
    $(function () {
        layui.use(['element', 'table', 'form'], function () {
            element = layui.element;
            laytable = layui.table;
            layfrom = layui.form;
            element.on('tab(zc)', function (data) {
                // mainApp.reloadTable();
                if (data.index == 0) {//众筹
                    window.location.href =
                        "${ctx}/crowdfund/analyze/list.do?targetId=${projectAnalyze.targetId}&eventId=${projectAnalyze.eventId}";
                } else if (data.index == 1) {//直接付款
                    window.location.href =
                        "${ctx}/crowdfund/analyze/directPayList.do?targetId=${projectAnalyze.targetId}&payType=1&eventId=${projectAnalyze.eventId}";
                }
            });

            // 初始化table
            var opts = {
                id: 'analyze_table'
                , elem: '#analyze_table'
                , url: '${ctx}/crowdfund/analyze/api/list.do' //数据接口
                , method: 'post'
                , where: {
                    labelId: '',
                    sort: '0',
                    targetId: '${projectAnalyze.targetId}',
                    eventId: '${projectAnalyze.eventId}',
                    isSuccess: '${projectAnalyze.isSuccess}',
                    payType: 0
                }
                , request: {
                    pageName: 'pageNo' //页码的参数名称，默认：page
                    , limitName: 'pageSize' //每页数据量的参数名，默认：limit
                }
                , limit: '30'
                , skin: '1'
                , page: {
                    theme: '#e8473f'
                } //开启分页
                , size: 'sm' //小尺寸的表格
                , height: 'full-250'
                , done: function (response) {
                    tableSel.init();
                    mainApp.changeBg();
                    layer.close(loadingIndex);
                    $('#total_1').html(response.count);
                }
                , cols: [[ //表头
                    {
                        field: 'num',
                        title: '序号',
                        width: 50,
                        fixed: 'left',
                        templet: '<div>{{d.LAY_INDEX}}</div>'
                    },
                    {
                        field: 'authorName',
                        title: '众筹者',
                        width: 100,
                        fixed: 'left'
                        ,
                        templet: '<div><textarea data-id="{{d.id}}" class="dn analyze-json-data">{{JSON.stringify(d)}}</textarea><div class="member-cell" onclick="openDialogNoButton(\'用户名片\',\'${ctx}/system/member/memberViewWithShare.do?id={{d.authorId}}&projectId={{d.id}}\',\'400px\',\'470px\')">\n' +
                            '     <img class="member-logo-img" src="{{ d.authorLogo }}?imageMogr2/auto-orient/crop/126x126" onerror=null;src=\'${ctx}/image/def_user_logo.png\' />' +
                            '     <div class="member-name ellipsis-1">' +
                            '       <a class="tdl" title="{{d.authorName}}" href="javascript:void(0);">{{d.authorName}}</a>\n' +
                            '     </div>\n' +
                            ' </div></div>'
                    }
                    , {field: 'publisher', title: '渠道商', width: 100, fixed: 'left'}
                    , {
                        field: 'represent', title: '联合发起人', width: 100, fixed: 'left'
                        , templet: '<div>' +
                            '   {{#  if(d.parentName){ }}' +
                            '    <div class="member-cell" onclick="txz.openDialogIframe({title:\'用户名片\',url:\'${ctx}/system/member/memberView.do?id={{d.parentId}}\',width:\'400px\',height: \'470px\'})">\n' +
                            '        <div class="member-name ellipsis-1"><a class="tdl" title="${d.parentName}" href="javascript:void(0);">{{d.parentName}}' +
                            '        </a></div>\n' +
                            '    </div>\n' +
                            '   {{#  } }}' +
                            '</div>'
                    }
                    , {
                        field: 'a-status', title: '参与状态', width: 100, fixed: 'left'
                        , templet: '<div><div class="j-table-sel-warp" data-id="{{d.id}}"\n' +
                            '     data-name="label">\n' +
                            '    <div class="sel-text"></div>\n' +
                            '    <ul class="j-table-sel">\n' +
                            '    {{# layui.each(${labelList}, function(index, label){ }}' +
                            '       <li onchange="mainApp.changeLabel" data-value="{{label.id}}" class="{{# if(label.id === d.labelId ){ }} active {{# } }}">{{ label.name}}</li>\n' +
                            '    {{# }); }}' +
                            '    </ul>\n' +
                            '</div></div>'
                    }
                    , {
                        field: 'records', title: '跟进记录', width: 100, fixed: 'left'
                        , templet: '<div><div class="j-table-sel-warp" data-id="{{d.id}}"\n' +
                            '      data-name="record" data-change-text="false">\n' +
                            '     <p class="sel-text  ellipsis-1">{{d.recentlyRecord || \'---\'}}</p>\n' +
                            '     <ul class="j-table-sel" data-id="{{d.id}}">\n' +
                            '         <li onchange="mainApp.changeRecordSel" data-value="0">新增跟进记录\n' +
                            '         </li>\n' +
                            '         <li onchange="mainApp.changeRecordSel" data-value="1">查看跟进记录\n' +
                            '         </li>\n' +
                            '     </ul>\n' +
                            ' </div></div>'
                    }
                    , {field: 'recentlyRecordTime', title: '最近跟进记录', width: 100, fixed: 'left'}
                    , {field: 'cityName', title: '区域', width: 80}
                    , {field: 'company', title: '公司', width: 80}
                    , {field: 'jobTitle', title: '职务', width: 80}
                    , {field: 'mobile', title: '联系电话', width: 100}
                    , {
                        field: 'isFriend', title: '加好友', width: 60
                        , templet: '<div><div class="j-table-sel-warp" data-id="{{d.id}}" data-name="isFriend">\n' +
                            '     <div class="sel-text"></div>\n' +
                            '     <ul class="j-table-sel" data-id="{{d.id}}">' +
                            '         <li onchange="mainApp.changeFriend" data-value="1"' +
                            '             class="{{# if(d.isFriend === \'是\'){}} active {{# } }}">是' +
                            '         </li>\n' +
                            '         <li onchange="mainApp.changeFriend" data-value="0"' +
                            '              class="{{# if(d.isFriend === \'否\'){}} active {{# } }}">否' +
                            '         </li>\n' +
                            '     </ul>\n' +
                            ' </div></div>'
                    }
                    , {
                        field: 'isPoster', title: '做海报', width: 60
                        , templet: '<div><div class="j-table-sel-warp" data-id="{{d.id}}" data-name="isPoster">\n' +
                            '     <div class="sel-text"></div>\n' +
                            '     <ul class="j-table-sel" data-id="{{d.id}}">' +
                            '         <li onchange="mainApp.changePoster" data-value="1"' +
                            '             class="{{# if(d.isPoster === \'是\'){}} active {{# } }}">是' +
                            '         </li>\n' +
                            '         <li onchange="mainApp.changePoster" data-value="0"' +
                            '              class="{{# if(d.isPoster === \'否\'){}} active {{# } }}">否' +
                            '         </li>\n' +
                            '     </ul>\n' +
                            ' </div></div>'
                    }
                    , {
                        field: 'isGroup', title: '入群状态', width: 60
                        , templet: '<div><div class="j-table-sel-warp" data-id="{{d.id}}" data-name="isGroup">\n' +
                            '     <div class="sel-text"></div>\n' +
                            '     <ul class="j-table-sel" data-id="{{d.id}}">' +
                            '         <li onchange="mainApp.changeGroup" data-value="1"' +
                            '             class="{{# if(d.isGroup === \'是\'){}} active {{# } }}">是' +
                            '         </li>\n' +
                            '         <li onchange="mainApp.changeGroup" data-value="0"' +
                            '              class="{{# if(d.isGroup === \'否\'){}} active {{# } }}">否' +
                            '         </li>\n' +
                            '     </ul>\n' +
                            ' </div></div>'
                    }
                    , {field: 'isSubscribe', title: '关注', width: 60}
                    , {field: 'isSuccess', title: '状态', width: 80}
                    , {
                        field: 'favorerNum',
                        title: '支持数',
                        width: 60
                        ,
                        templet: '<div><a target="_blank" href="javascript:mainApp.forwardSupport(\'${projectAnalyze.eventId}\', \'${projectAnalyze.targetId}\', \'{{d.id}}\',\'{{d.isSuccess}}\',\'{{d.actualAmount}}\');" class="tdl favorerNum count-num">{{d.favorerNum}}</a></div>'
                    }
                    , {field: 'targetAmount', title: '目标金额', width: 80}
                    , {
                        field: 'actualAmount',
                        title: '支持金额',
                        width: 60
                        ,
                        templet: '<div><a target="_blank" href="javascript:mainApp.forwardSupport(\'${projectAnalyze.eventId}\', \'${projectAnalyze.targetId}\', \'{{d.id}}\',\'{{d.isSuccess}}\',\'{{d.actualAmount}}\');" class="tdl actualAmount count-num">{{d.actualAmount}}</a></div>'
                    }
                    , {field: 'viewNum', title: '阅读数', width: 60}
                    , {
                        field: 'qrCodeUrl',
                        title: '二维码',
                        width: 50
                        ,
                        templet: '<div><a class="qr-btn" href="javascript:txz.openQrDialog({title:\'扫码二维码可预览分享\',detailList:[{title:\'众筹详情二维码\',url:\'{{d.qrCodeUrl}}\',link:\'{{d.url}}\'}]})"> 链接</a>'
                    }
                    , {
                        field: 'createDate', title: '报名时间', width: 70
                        , templet: '<div>{{util.getDateStr(d.createDate).Format(\'yy/MM/dd\')}}</div>'
                    }
                    , {
                        field: 'lastSupportDate', title: '成功时间', width: 130
                        , templet: '<div /"width:130px/">{{# if(d.isSuccess == \'众筹成功\'){ }} {{util.getDateStr(d.lastSupportDate).Format(\'yyyy-MM-dd HH:mm:ss\')}} {{# } }}</div>'
                    }
                    , {
                        field: 'stagnationDays', title: '众筹停滞', width: 60
                        , templet: '<div> {{# if(d.isSuccess == \'众筹中\'){ }} {{d.stagnationDays}}天 {{# } }}</div>'
                    }
                    , {
                        field: 'useTime',
                        title: '众筹用时',
                        width: 100
                        ,
                        templet: '<div /"width:100px/"> {{# if(d.isSuccess == \'众筹中\'||d.isSuccess == \'众筹成功\'){ }} {{d.useTime||\'\'}} {{# } }}</div>'
                    }

                ]]
            }
            for (var i = 0; i < dateList.length; i++) {
                opts.cols[0].push({
                    field: 'date-' + i, title: dateList[i], width: 70
                    , templet: '<div><div class="{{# if(d.isSuccess != \'众筹成功\'){}}' +
                        '{{# if(d.moneyMap[\'' + dateList[i + 1] + '\'] == d.moneyMap[\'' + dateList[i] + '\'] || d.moneyMap[\'' + dateList[i - 1] + '\']== d.moneyMap[\'' + dateList[i] + '\']){}}' +
                        'analyze-td-gray' +
                        '{{# } }}' +
                        '{{# } }}">{{d.moneyMap[\'' + dateList[i] + '\'] == -1 ? 0:d.moneyMap[\'' + dateList[i] + '\']}}</div></div>'
                })
            }
            analyzeT = laytable.render(opts);
        });
        mainApp = {
            reloadTable: function () {
                loadingIndex = layer.load(1);
                var formData = util.serializeForm($('#myForm').serializeArray());
                formData['targetId'] = '${projectAnalyze.targetId}'
                formData['eventId'] = '${projectAnalyze.eventId}'
                analyzeT.reload({
                    where: formData,
                    page: {
                        theme: '#e8473f',
                        curr: 1 //重新从第 1 页开始
                    }
                });
            },
            setLabel: function (o, value) {
                $('input[name=labelId]').val(value);
                $('#timeType .active').removeClass('active');
                $(o).addClass('active');
                mainApp.reloadTable();
            },
            changeBg: function () {
                $('.analyze-json-data').each(function () {
                    var data = JSON.parse($(this).val());
                    $(this).closest('tr').find('td').css('background-color', data.style);
                })
                $('.analyze-td-gray').each(function () {
                    $(this).closest('td').css('background-color', '#bbb');
                })
            },
            openDialog: function (title, url, width, height, target) {
                layer.open({
                    type: 2,
                    area: [width, height],
                    title: title,
                    maxmin: true, //开启最大化最小化按钮
                    content: url,
                    btn: ['确定', '关闭'],
                    yes: function (index, layero) {
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                        var inputForm = body.find('#inputForm');
                        var top_iframe;
                        if (target) {
                            top_iframe = target;//如果指定了iframe，则在改frame中跳转
                        } else {
                            top_iframe = '_parent';//获取当前active的tab的iframe
                        }
                        inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                        if (iframeWin.contentWindow.doSubmit()) {
                            setTimeout(function () {
                                top.layer.close(index);
                            }, 100);//延时0.1秒，对应360 7.1版本bug

                            setTimeout(function () {
                                window.location.reload();
                            }, 200);
                        }
                    },
                    cancel: function (index) {
                    }
                });
            },
            changeRecordSel: function (data) {
                if (data.value == 0) {
                    mainApp.changeRecords(data.id, '新增跟进记录', '${ctx}/records/records/asynView.do?projectId=' + data.id, '1050px', '720px');
                } else if (data.value == 1) {
                    txz.openDialogIframe({
                        url: '${ctx}/records/records/list.do?targetId=' + data.id + '&activityId=${projectAnalyze.targetId}&eventId=${projectAnalyze.eventId}',
                        title: '跟进记录',
                        width: '900px',
                        height: '500px',
                        btn: [],
                        cb: function () {

                        }
                    })
                }
            },
            changeRecords: function (id, title, url, width, height, target) {
                layer.open({
                    type: 2,
                    area: [width, height],
                    title: title,
                    maxmin: true, //开启最大化最小化按钮
                    content: url,
                    btn: ['确定', '关闭'],
                    yes: function (index, layero) {
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                        var inputForm = body.find('#inputForm');
                        var top_iframe;
                        if (target) {
                            top_iframe = target;//如果指定了iframe，则在改frame中跳转
                        } else {
                            top_iframe = '_parent';//获取当前active的tab的iframe
                        }
                        inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                        var value = iframeWin.contentWindow.doSubmit();
                        if (util.isValid(value)) {
                            var $temps = $('.analyze-json-data[data-id="' + id + '"]');
                            $temps.each(function () {
                                var $tr = $(this).closest('tr');
                                $tr.find('[data-name="record"]').find('.sel-text').text(value);
                                var date = new Date();
                                var dateStr = date.Format('MM/dd') + "  " + "0天前";
                                $tr.find('[data-field="recentlyRecordTime"] .layui-table-cell').text(dateStr);
                            })
                            setTimeout(function () {
                                top.layer.close(index);
                            }, 100);//延时0.1秒，对应360 7.1版本bug
                        }
                    },
                    cancel: function (index) {
                    }
                });
            },

            changeLabel: function (data) {
                $.post('${ctx}/crowdfund/analyze/labelSave.do', {
                    id: data.value,
                    projectId: data.id
                }, function (res) {
                    if (res.success) {
                        var $temps = $('.analyze-json-data[data-id="' + data.id + '"]');
                        $temps.each(function () {
                            var $tr = $(this).closest('tr');
                            $tr.find('td').css('background-color', res.data);
                            $tr.find('.analyze-td-gray').closest('td').css('background-color', '#bbb');
                        })
                        util.layerMsgSuccess("提交成功", function () {
                        });
                    } else {
                        util.layerMsgError(res.description)
                    }
                });
            },

            changeFriend: function (data) {
                $.post("${ctx}/crowdfund/analyze/changeFriend.do", {
                    projectId: data.id, status: data.value
                }, function (data) {
                    if (data.success) {
                    } else {
                        util.layerAlertError("操作失败")
                    }
                });
            },

            changePoster: function (data) {
                $.post("${ctx}/crowdfund/analyze/changePoster.do", {
                    projectId: data.id, status: data.value
                }, function (data) {
                    if (data.success) {
                    } else {
                        util.layerAlertError("操作失败")
                    }
                });
            },

            changeGroup: function (data) {
                $.post("${ctx}/crowdfund/analyze/changeGroup.do", {
                    projectId: data.id, status: data.value
                }, function (data) {
                    if (data.success) {
                    } else {
                        util.layerAlertError("操作失败")
                    }
                });
            },
            forwardSupport: function (eventId, targetId, projectId, isSuccess, actualAmount) {
                if (isSuccess == '众筹中' && actualAmount == 0) {
                    return;
                }
                if (eventId != "") {
                    window.open('${ctx}/crowdfund/support/event/listForProjectId.do?eventId=' + eventId + '&projectId=' + projectId, "_blank");
                } else if (targetId != "") {
                    window.open('${ctx}/crowdfund/support/listForProjectId.do?projectId=' + projectId + '&id=' + targetId, "_blank");
                }
            }
        }

        $("body").ready(function () {
            opSelect();
        });

        function opSelect(isSuccess) {
            var opNameArrs = [
                "金额最多",
                "报名时间最近",
                "支持数最多",
                "阅读量最多",
                "众筹用时最少",
                "成功时间最近"
            ];
            var $opSelect = $("#opSelect");
            for (var i = 0; opNameArrs.length > i; i++) {
                $opSelect.append("<option value='" + i + "'>" + opNameArrs[i] + "</option>");
            }
        }

        $("ul#zc_tab").on("click", "li", function () {
            var $opSelect = $("#opSelect");
            var liv = $(this).data("value");
            var opV5 = $("#opSelect option[value='5']");
            // console.log(opV5)
            if (!(liv === "" || liv === 1)) {
                opV5.remove();
            } else {
                if (opV5.length == 0) {
                    $opSelect.append("<option value='" + 5 + "'>" + "成功时间最近" + "</option>")
                }

            }
            layfrom.render('select');
        });
    })

    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var url = "${ctx}/crowdfund/analyze/listExport.do?targetId=${projectAnalyze.targetId}&eventId=${projectAnalyze.eventId}";
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post(url, $("#myForm").serialize(), function (res) {
                top.layer.close(loadIndex);
                if (res.success) {
                    window.location.href = res.data;
                } else {
                    util.layerMsgError(res.description)
                }
            });
            top.layer.close(index);
        });
    }
</script>
</body>
</html>
